/*     */ package com.feeyin.radar.sys.controller;
/*     */ 
/*     */ import com.feeyin.radar.commons.ListPage;
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.sys.form.BackupForm;
/*     */ import com.feeyin.radar.sys.service.BackupDataService;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletContext;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
/*     */ import org.springframework.web.servlet.view.RedirectView;
/*     */ 
/*     */ public class BackupManageController extends MultiActionController
/*     */ {
/*     */   private BackupDataService backupDataService;
/*     */   private String backupManage;
/*     */   private String autoBackup;
/*     */ 
/*     */   public BackupDataService getBackupDataService()
/*     */   {
/*  33 */     return this.backupDataService;
/*     */   }
/*     */ 
/*     */   public void setBackupDataService(BackupDataService backupDataService) {
/*  37 */     this.backupDataService = backupDataService;
/*     */   }
/*     */ 
/*     */   public String getBackupManage() {
/*  41 */     return this.backupManage;
/*     */   }
/*     */ 
/*     */   public void setBackupManage(String backupManage) {
/*  45 */     this.backupManage = backupManage;
/*     */   }
/*     */ 
/*     */   public String getAutoBackup() {
/*  49 */     return this.autoBackup;
/*     */   }
/*     */ 
/*     */   public void setAutoBackup(String autoBackup) {
/*  53 */     this.autoBackup = autoBackup;
/*     */   }
/*     */ 
/*     */   public ModelAndView display(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  58 */     Map model = new HashMap();
/*  59 */     model.put("result", request.getParameter("result"));
/*  60 */     String realPath = getServletContext().getRealPath("/");
/*     */ 
/*  64 */     ListPage page = new ListPage();
/*  65 */     ListPage.getPageList(this.backupDataService.getPageBackupDatas(realPath), null, request);
/*  66 */     model.put("backupDatas", this.backupDataService.getPageBackupDatas(realPath));
/*  67 */     model.put("backupPath", getServletContext().getRealPath("/") + "backup");
/*  68 */     return new ModelAndView(getBackupManage(), model);
/*     */   }
/*     */ 
/*     */   public ModelAndView nowBackup(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  73 */     boolean result = false;
/*  74 */     int success = 0;
/*  75 */     String realPath = getServletContext().getRealPath("/");
/*  76 */     result = this.backupDataService.insertBackupData(realPath, "1");
/*  77 */     if (result) success = 1;
/*  78 */     return new ModelAndView(new RedirectView("./backupManage.do?action=display&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView restoreData(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  83 */     boolean result = false;
/*  84 */     int success = 0;
/*  85 */     String path = request.getParameter("id");
/*  86 */     if (!StringUtils.isEmpty(path)) {
/*  87 */       String realPath = getServletContext().getRealPath("/");
/*  88 */       result = this.backupDataService.restoreData(realPath, path);
/*  89 */       if (result) success = 2;
/*     */     }
/*  91 */     return new ModelAndView(new RedirectView("./backupManage.do?action=display&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView preAutoBackup(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  96 */     Map model = new HashMap();
/*  97 */     model.put("result", request.getParameter("result"));
/*  98 */     model.put("backupForm", this.backupDataService.getBackupPlan());
/*  99 */     model.put("backupPath", getServletContext().getRealPath("/") + "backup");
/* 100 */     return new ModelAndView(getAutoBackup(), model);
/*     */   }
/*     */ 
/*     */   public ModelAndView autoBackup(HttpServletRequest request, HttpServletResponse response, BackupForm backupForm)
/*     */   {
/* 105 */     boolean result = false;
/* 106 */     int success = 0;
/* 107 */     if (backupForm != null) {
/* 108 */       result = this.backupDataService.insertBackupPlan(backupForm);
/* 109 */       if (result) success = 1;
/*     */     }
/* 111 */     return new ModelAndView(new RedirectView("./backupManage.do?action=preAutoBackup&result=" + success));
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.controller.BackupManageController
 * JD-Core Version:    0.6.0
 */